package com.own.demo.lwf.threadTest;

/**
 * @version v1.0
 * @Description:java练习
 * @Author 李文峰
 * @Date 2023/4/30 0030 16:30
 */
public class TestNewRunnable {
    public static void main(String[] args) {
        newRunnable();
    }
    public static void newRunnable(){
        // 创建线程t1，重写run()方法
        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 3; i++) {
                    System.out.println("thread t1 --" + i);
                    try {
                        Thread.sleep(1000L);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        },"t1").start();

        // 创建线程t2
        new Thread(()->{
            for (int i = 0; i < 3; i++) {
                System.out.println("thread t2 --" + i);
                try {
                    Thread.sleep(1000l);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"t2").start();
    }
}
